<html>
<head><meta charset="utf-8"><title>simd-pass-by-value · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html">simd-pass-by-value</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="135902307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135902307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135902307">(Oct 16 2018 at 14:10)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> would you be up to review <a href="https://github.com/rust-lang/rust/issues/55073" target="_blank" title="https://github.com/rust-lang/rust/issues/55073">#55073</a>? It's a PR by <span class="user-mention" data-user-id="116015">@Alex Crichton</span> to ensure we pass SIMD arguments by value</p>



<a name="135902310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135902310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135902310">(Oct 16 2018 at 14:10)</a>:</h4>
<p>Not sure who would be a good choice, it's basically a big blob of C++ code</p>



<a name="135902713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135902713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135902713">(Oct 16 2018 at 14:18)</a>:</h4>
<p>I'd volunteer but I am not sure I'll have the time to do it in the next few days</p>



<a name="135903302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135903302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135903302">(Oct 16 2018 at 14:26)</a>:</h4>
<p>I skimmed it but I don't really know much about LLVM IR</p>



<a name="135903446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135903446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135903446">(Oct 16 2018 at 14:28)</a>:</h4>
<p>From skimming it seems like the exact sort of fiddly IR manipulation which I'm accustomed to, but that doesn't free me from having to read it very carefully, which takes time =/</p>



<a name="135904114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135904114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135904114">(Oct 16 2018 at 14:36)</a>:</h4>
<p>I did give it a pass.</p>



<a name="135904124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135904124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135904124">(Oct 16 2018 at 14:36)</a>:</h4>
<p>I’d rather an alternative approach <span class="emoji emoji-1f642" title="slight smile">:slight_smile:</span></p>



<a name="135905077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905077">(Oct 16 2018 at 14:51)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> do you know if it is possible to have arbitrary attributes on functions/arguments/etc?</p>



<a name="135905082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905082">(Oct 16 2018 at 14:51)</a>:</h4>
<p>It is!</p>



<a name="135905089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905089">(Oct 16 2018 at 14:51)</a>:</h4>
<p>You can create an attribute out of an arbitrary string</p>



<a name="135905206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905206">(Oct 16 2018 at 14:53)</a>:</h4>
<p>hmm… <span class="user-mention" data-user-id="116015">@Alex Crichton</span> would you mind looking into whether the promotion strips those arbitrary "strings"?</p>



<a name="135905266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905266">(Oct 16 2018 at 14:54)</a>:</h4>
<p>I’d be entrely fine with r+ing that PR if it didn’t also demote that "#[nomangle] extern" function</p>



<a name="135905301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905301">(Oct 16 2018 at 14:55)</a>:</h4>
<p>Promotion (and other passes that fiddle with the signature) should copy over function attributes. Many of them are important for semantics, and many others should be preserved because they are really important for optimizations.</p>



<a name="135905323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905323">(Oct 16 2018 at 14:55)</a>:</h4>
<p>if LLVM does not end up stripping our custom attribute you then could selectively demote only the arguments with our attribute (i.e. we know for sure it is fine to demote those)</p>



<a name="135905438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905438">(Oct 16 2018 at 14:57)</a>:</h4>
<p>Oh do you mean a function attribute or a parameter attribute? The latter can't be blindly copied over so I'm less sure what arg promotion does to it</p>



<a name="135905449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905449">(Oct 16 2018 at 14:57)</a>:</h4>
<p>Since this is really about Rust ABI vs other ABIs, a function attribute should be sufficient</p>



<a name="135905459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905459">(Oct 16 2018 at 14:57)</a>:</h4>
<blockquote>
<p>Oh do you mean a function attribute or a parameter attribute? The latter can't be blindly copied over so I'm less sure what arg promotion does to it</p>
</blockquote>
<p>I meant parameter one, but I think argument one would be just fine as well, I think</p>



<a name="135905465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905465">(Oct 16 2018 at 14:57)</a>:</h4>
<p>During argument promotion <a href="https://github.com/llvm-mirror/llvm/blob/0f096ec04e276fa55a493238b33b1ea10982f3d5/lib/Transforms/IPO/ArgumentPromotion.cpp#L199" target="_blank" title="https://github.com/llvm-mirror/llvm/blob/0f096ec04e276fa55a493238b33b1ea10982f3d5/lib/Transforms/IPO/ArgumentPromotion.cpp#L199">argument parameters are lost</a></p>



<a name="135905512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905512">(Oct 16 2018 at 14:58)</a>:</h4>
<p>I think though we can probably skip all non-internal functions in demotion</p>



<a name="135905515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905515">(Oct 16 2018 at 14:58)</a>:</h4>
<p>at least I cannot immediately think of a case where for our use-case there would be any difference between two.</p>



<a name="135905517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905517">(Oct 16 2018 at 14:58)</a>:</h4>
<p>and that should skip the boundary and not affect the correctness at all</p>



<a name="135905530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905530">(Oct 16 2018 at 14:58)</a>:</h4>
<p>A lot of Rust-ABI functions are external, but I guess those wouldn't get their arguments promoted in the first place?</p>



<a name="135905573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905573">(Oct 16 2018 at 14:59)</a>:</h4>
<p>correct</p>



<a name="135905576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905576">(Oct 16 2018 at 14:59)</a>:</h4>
<p>Right. I would be fine with skipping the external functions as well.</p>



<a name="135905578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905578">(Oct 16 2018 at 14:59)</a>:</h4>
<p>argument promotion only runs on internal functions</p>



<a name="135905682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905682">(Oct 16 2018 at 15:00)</a>:</h4>
<p>It's hypothetically possible that a function is internal when argument promotion runs and is made external afterwards. I don't think that would actually happen though.</p>



<a name="135905714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905714">(Oct 16 2018 at 15:01)</a>:</h4>
<p>One nice thing about the attribute route, though, is that we could also patch argument promotion to not promote functions with that attribute (would be a small patch)</p>



<a name="135905802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905802">(Oct 16 2018 at 15:02)</a>:</h4>
<p>We should really avoid patching our own LLVM like that, though, because there are users with their own LLVM versions patched to various degrees.</p>



<a name="135905808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905808">(Oct 16 2018 at 15:02)</a>:</h4>
<p>but yeah.</p>



<a name="135905828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/simd-pass-by-value/near/135905828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/simd-pass-by-value.html#135905828">(Oct 16 2018 at 15:03)</a>:</h4>
<p>I wouldn't want to rely <em>solely</em> on that, even when building with our LLVM fork, since there might be other passes that do a similar transformation, but it would be almost-free defense-in-depth</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>